1. Field of the Invention
Methods and apparatuses consistent with the present invention relate to motion compensation, and more particularly, to a video encoding/decoding using directional interpolation for improving motion compensation accuracy.
2. Description of the Related Art
According to the moving picture experts group (MPEG)-1, MPEG-2, MPEG-4, and H.264 encoding standards, P-picture encoding, in which the current picture is encoded by referring to a previous picture, and B-picture encoding, in which the current picture is encoded by referring to both a previous picture and a future picture, are adopted, and motion compensation is performed based on P-picture encoding and B-picture encoding. In particular, according to the MPEG-4 or H.264 encoding standard, motion compensation is performed in units of a macroblock or on each of a plurality of blocks obtained by dividing a macroblock. Motion compensation is performed after interpolation for obtaining half pixels, quarter pixels, or one eighth pixels is performed on a block composed of integer pixels to improve the accuracy of data.
FIG. 1 is a reference diagram for explaining half-pixel interpolation.
Referring to FIG. 1, gray boxes indicate original pixels and white boxes indicate interpolation pixels. The original pixels mean integer pixels. In FIG. 1, the interpolation pixels 5, 6, 7, 8, and 9 indicate half pixels. Each of the half pixels is obtained based on its vertically or horizontally adjacent integer pixels or half pixels. For example, the half pixel 5 is obtained based on the integer pixels 1 and 2 and the half pixel 8 is obtained based on the integer pixels 3 and 4. The half pixel 6 is obtained based on the integer pixels 1 and 3 and the half pixel 7 is obtained based on the integer pixels 2 and 4. The half pixel 9 is obtained based on the half pixels 5 and 8 or the half pixels 6 and 7. Although the number of integer pixels is limited to 4 for convenience of explanation, the number of pixels used in interpolation may be adjusted properly. For example, the half pixel 5 may be obtained based on not only the integer pixels 1 and 2 but also its horizontally adjacent integer pixels. The interpolation pixels are indicated by integers within the same range as the original pixels. For example, if the original pixels are indicated by integers within a range of 0-255, the interpolation pixels also are indicated by integers within a range of 0-255.
FIG. 2 is a reference diagram for explaining interpolation used for quarter pixel interpolation of luminance components in H.264, in which some pixels of a predetermined motion compensation block are illustrated. In FIG. 2, gray boxes indicate integer pixels and white boxes indicate interpolation pixels.
In interpolation of FIG. 2, a plurality of pixels, i.e., 6 pixels, are used to obtain a single interpolation pixel. In addition, each of the pixels used in interpolation is given a weight. To this end, a 6-tap filter is used. The 6-tap filter has 6 tap values. The tap values mean weights given to the pixels used in interpolation. For example, tap values (1, −5, 20, 20, −5, 1) may be used. Various numbers of pixels may be used in interpolation and various weights, i.e., tap values, may be given thereto.
<Half Pixel b>
To obtain the half pixel b, 6 integer pixels E, F, G, H, I, and J that are horizontally adjacent to the half pixel b are used. If the foregoing 6-tap filter is applied to the integer pixels E, F, G, H, I, and J, a horizontal sum b1 is obtained as follows:b1=(E−5*F+20*G+20*H−5*I+J)   (1)
Next, 16 is added to the horizontal sum b1, the result of the addition is divided by 32, the result of the division is made an integer, and range adjustment is performed on the integer, thereby finally obtaining the half pixel b, as follows:b=Clip1Y((b1+16)>>5)   (2),
where the result of addition, i.e., b1+16, is made an integer by rounding off. ┌>>5┘ indicates dividing the result of the addition by 32 (=25) and then rounding off the result of the division to the nearest integer. This is because, since the sum of the tap values of the 6-tap filter is 32 (i.e., 32 pixel values are added), the average can be obtained by dividing the result of the addition by 32. Clip1Y( ) maps the obtained integer, i.e., (b1+16)>>5, to one within a range of integers indicating the original pixels (integer pixels). For example, when integer pixels are indicated by integers within a range of 0-255, if the obtained integer falls outside this range, Clip1Y( ) maps the obtained integer to a predetermined value within the range.
<Half Pixel h>
To obtain the half pixel h, 6 integer pixels A, C, G, M, R, and T that are vertically adjacent to the half pixel h are used. If the foregoing 6-tap filter is applied to the integer pixels A, C, G, M, R, and T, a vertical sum h1 is obtained as follows:h1=(A−5*C+20*G+20*M−5*R+T)   (3)
Next, 16 is added to the vertical sum h1, the result of the addition is divided by 32, an average is obtained by rounding off the result of division, and range adjustment is performed on the average, thereby finally obtaining the half pixel h, as follows:h=Clip1Y((h1+16)>>5)   (4)
<Half Pixel j>
The half pixel j can be obtained in a similar manner as the half pixel h. In other words, the half pixel j is obtained as follows:j1=(cc−5*dd+20*h1+20*m1−5*ee+ff) orj1=(aa−5*bb+20*b1+20*s1−5*gg+hh)   (5)j=Clip1Y((1+512)>>10)   (6)
<Quarter Pixel a>
To obtain the quarter pixel a, a horizontal average filter of half pixels and half pixels that are adjacent to the quarter pixel a is used. For example, the quarter pixel a is obtained as follows:a=(G+b+1)>>1   (7),
where (G+b+1) >>1 indicates adding 1 to (G+b), dividing the result of the addition by 2, and making the result of division an integer by rounding off the result of division to the nearest integer. The remaining quarter pixels c, d, n, f, j, k, and q also are obtained as follows:c=(H+b+1)>>1   (8)d=(G+h+1)>>1   (9)n=(M+h+1)>>1   (10)f=(b+j+1)>>1   (11)i=(h+j+1)>>1   (12)k=(j+m+1)>>1   (13)k=(j+s+1)>>1   (14)
FIG. 3 is a view for explaining interpolation of chrominance components in H.264. In interpolation according to H.264, luminance components and chrominance components are processed in different manners. The predictive interpolation value of a chrominance signal is obtained by performing linear interpolation on integer pixels with ⅛-pixel accuracy. The motion vector of a chrominance frame is ½ the magnitude of that of a luminance frame. Once the motion vector is determined, a predictive interpolation value v is determined as follows:v=((8−dx)(8−dy)*A+dx(8−dy)*B+(8−dx)*dy*C+dx*dy*D+32)>>6   (15),
where dx and dy are values indicating the motion vector of the chrominance frame.
As can be appreciated from FIGS. 2 and 3, related art sub-pixel interpolation is performed only horizontally or vertically without considering the characteristics of a video, resulting in degradation of the accuracy of interpolation and motion compensation using the interpolation.